package genmai
import(
	"fmt"
    "bytes"
	"os/exec"
	"os"
	"strings"
)
func Update(){
	currentDir, err:= os.Getwd()
	if err != nil {
		panic(err)
	} else {
	}
	currentDir=currentDir+"/../"
	os.Chdir(currentDir)

	currentDir, err = os.Getwd()
	if err != nil {
		panic(err)
	} else {
		cmd := exec.Command("git","pull")
		var stdout, stderr bytes.Buffer
		cmd.Stdout = &stdout // 标准输出
		cmd.Stderr = &stderr // 标准错误
		err := cmd.Run()
		outStr, errStr := string(stdout.Bytes()), string(stderr.Bytes())
		if len(errStr)!=0{
			fmt.Printf(errStr)
		}
		outStr=strings.TrimSpace(outStr)
		if err != nil {
			fmt.Println("Updte Err:", err)
		}
		fmt.Println(outStr)
	}

}